package com.youpai.platform.chat.web.api;

import com.youpai.platform.chat.service.entity.dto.ChatMessageDTO;
import com.youpai.platform.chat.service.service.ChatMessageService;
import com.youpai.platform.chat.web.entity.req.RecallMessageReq;
import com.youpai.platform.chat.web.entity.req.SyncMsgListRequest;
import com.youpai.platform.chat.web.entity.resp.RecallMessageResp;
import com.youpai.platform.common.entity.resp.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * @Description: 历史消息相关
 * @Author:welles
 * @Date:2022/7/23
 */
@Slf4j
@RestController
@RequestMapping(value = "/chat/msg")
@Api(value = "ChatMessageController", tags = "历史消息相关")
public class ChatMessageController {

    @Resource
    private ChatMessageService chatMessageService;

    @ApiOperation(value = "查询历史消息")
    @PostMapping(value = "/list/query")
    public BaseResponse<List<ChatMessageDTO>> syncMsgListRequest(@RequestBody SyncMsgListRequest req) {
        return BaseResponse.success(chatMessageService.syncMsgListRequest(req));
    }

    @ApiOperation(value = "撤回消息")
    @PostMapping(value = "/recall")
    public BaseResponse<RecallMessageResp> recallTheMessage(@RequestBody RecallMessageReq req) {
        return BaseResponse.success(chatMessageService.recallTheMessage(req));
    }


}
